package com.aba.dormitory.system.teacher;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Teacher {
    private static final String USERNAME = "teacher";
    private static final String PASSWORD = "111";

    private static List<String> students = new ArrayList<>();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        boolean isLoggedIn = false;

        // 登录逻辑
        while (!isLoggedIn) {
            System.out.println("请输入老师账号：");
            String inputUsername = scanner.nextLine();

            System.out.println("请输入密码：");
            String inputPassword = scanner.nextLine();

            if (inputUsername.equals(USERNAME) && inputPassword.equals(PASSWORD)) {
                System.out.println("登录成功！");
                isLoggedIn = true;
            } else {
                System.out.println("用户名或密码错误，请重新输入！");
            }
        }

        // 主功能逻辑
        while (true) {
            System.out.println("请输入命令（add添加学生信息，delete删除学生信息，list查看学生信息，exit退出系统）：");
            String command = scanner.nextLine();

            switch (command.toLowerCase()) {
                case "add":
                    System.out.println("请输入要添加的学生名称：");
                    String studentToAdd = scanner.nextLine();
                    if (!students.contains(studentToAdd)) {
                        students.add(studentToAdd);
                        System.out.println("学生 " + studentToAdd + " 添加成功");
                    } else {
                        System.out.println("学生 " + studentToAdd + " 已经存在");
                    }
                    break;
                case "delete":
                    System.out.println("请输入要删除的学生名称：");
                    String studentToDelete = scanner.nextLine();
                    if (students.contains(studentToDelete)) {
                        students.remove(studentToDelete);
                        System.out.println("学生 " + studentToDelete + " 删除成功");
                    } else {
                        System.out.println("学生 " + studentToDelete + " 不存在");
                    }
                    break;
                case "list":
                    System.out.println("当前学生列表：");
                    if (students.isEmpty()) {
                        System.out.println("暂无学生信息");
                    } else {
                        for (String student : students) {
                            System.out.println(student);
                        }
                    }
                    break;
                case "exit":
                    System.out.println("退出系统成功！");
                    scanner.close();
                    return;
                default:
                    System.out.println("未知命令，请输入add、delete、list或exit");
            }
        }
    }
}
